﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SMALLERP.DataClass;

namespace XJLSC.QM
{
    public partial class GZZXKC : Form
    {
        public GZZXKC()
        {
            InitializeComponent();
        }
        private readonly DataBase db = new DataBase();
        private void GZZXKC_Load(object sender, EventArgs e)
        {
            string strSql = null;

            strSql = "SELECT MD001 工作中心,MD002 工作中心名称 FROM CMSMD";
            try
            {
                dataGridView1.DataSource = db.GetDataSet1(strSql, "CMSMD").Tables["CMSMD"];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "软件提示");
                throw ex;
            }
        }

        public string UserId
        {
            get
            {
                return _UserId;
            }
        }
        string _UserId;


        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName
        {
            get
            {
                return _UserName;
            }
        }
        string _UserName;
        public event EventHandler DataSelected;
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {   
            if (this.DataSelected != null)
            {
                this._UserId = dataGridView1.Rows[e.RowIndex].Cells["工作中心"].Value.ToString();
                this._UserName = dataGridView1.Rows[e.RowIndex].Cells["工作中心名称"].Value.ToString();
                // 引发事件
                this.DataSelected(null, null);
            }
            this.Close();  // 关闭本窗体
        }
    }
}
